<!DOCTYPE html>
<html lang="zh" ng-app="myApp" xmlns="http://www.w3.org/1999/html">
<head>
	<meta charset="UTF-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<title>汪卡在线微信平台用户注册</title>
	<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0"/>
	<foreach name="meta" item="vo">
		<meta name="{$key}" content="{$vo}">
	</foreach>
	<foreach name="wxconfig" item="vo">
		<meta name="{$key}" content="{$vo}">
	</foreach>
	<link rel="stylesheet" href="/Public/node_modules/weui/dist/style/weui.min.css">
	<link rel="stylesheet" href="/Public/node_modules/font-awesome/css/font-awesome.min.css">
	<link rel="stylesheet" href="/Public/node_modules/weui/dist/example/example.css">
	<style>
		li.weui_uploader_file{width:150px;height: 120px;}
		li.weui_uploader_file>img{width:150px;height: 120px;}
		div.weui_uploader_input_wrp{ width: 120px; height: 120px;}
		.hidden{display:none}
	</style>
</head>
<body>
<div class="container">
	<div class="hd">
		<h3 class="page_title">新用户注册</h3>
	</div>
	<div class="bd" ng-controller="registerCtrl">
		<div class="weui_cells_title">请填写用户手机号码</div>
		<div class="weui_cells">
			<div class="weui_cell">
				<div class="weui_cell_hd"><i class="fa fa-user"></i> </div>
				<div class="weui_cell_bd weui_cell_primary">
					<p> 手机号码</p>
				</div>
				<div class="weui_cell_ft">
					<input type="tel" name="mobile" ng-mode="register.mobile" class="weui_input">
				</div>
			</div>
		</div>
		<div class="weui_cells_title">请填写用户登录密码</div>
		<div class="weui_cells">
			<div class="weui_cell">
				<div class="weui_cell_hd"><i class="fa fa-user"></i> </div>
				<div class="weui_cell_bd weui_cell_primary">
					<p> 登录密码</p>
				</div>
				<div class="weui_cell_ft">
					<input type="text" name="password" ng-mode="register.password" class="weui_input">
				</div>
			</div>
		</div>
		<div class="weui_cells_title">请重新填写用户登录密码</div>
		<div class="weui_cells">
			<div class="weui_cell">
				<div class="weui_cell_hd"><i class="fa fa-user"></i> </div>
				<div class="weui_cell_bd weui_cell_primary">
					<p> 重复密码</p>
				</div>
				<div class="weui_cell_ft">
					<input type="tel" name="repassword" ng-mode="register.repassword" class="weui_input">
				</div>
			</div>
		</div>
		<div class="bd spacing">
			<button class="weui_btn weui_btn_primary" ng-click="submit()">确认并注册新用户</button>
		</div>
	</div>
</div>
<div style="height: 20px"></div>
<div id="loading_toast" class="weui_loading_toast" style="display: none">
	<div class="weui_mask_transparent"></div>
	<div class="weui_toast">
		<div class="weui_loading">
			<div class="weui_loading_leaf weui_loading_leaf_0"></div>
			<div class="weui_loading_leaf weui_loading_leaf_1"></div>
			<div class="weui_loading_leaf weui_loading_leaf_2"></div>
			<div class="weui_loading_leaf weui_loading_leaf_3"></div>
			<div class="weui_loading_leaf weui_loading_leaf_4"></div>
			<div class="weui_loading_leaf weui_loading_leaf_5"></div>
			<div class="weui_loading_leaf weui_loading_leaf_6"></div>
			<div class="weui_loading_leaf weui_loading_leaf_7"></div>
			<div class="weui_loading_leaf weui_loading_leaf_8"></div>
			<div class="weui_loading_leaf weui_loading_leaf_9"></div>
			<div class="weui_loading_leaf weui_loading_leaf_10"></div>
			<div class="weui_loading_leaf weui_loading_leaf_11"></div>
		</div>
		<p class="weui_toast_content">数据传递中</p>
	</div>
</div>
<div id="dialog_alert" class="weui_dialog_alert animate-show" style="display: none">
	<div class="weui_mask"></div>
	<div class="weui_dialog">
		<div class="weui_dialog_hd"><strong class="weui_dialog_title">操作提示</strong></div>
		<div class="weui_dialog_bd" id="dialog_content"></div>
		<div class="weui_dialog_ft">
			<a href="javascript:;" class="weui_btn_dialog primary" onclick="closeWindows()">确定</a>
		</div>
	</div>
</div>
<script type="text/javascript" src="/Public/node_modules/angular/angular.min.js"></script>
<script type="text/javascript" src="/Public/node_modules/jquery/dist/jquery.min.js"></script>
<script type="text/javascript" src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
<script type="text/javascript">
	var meta = new Object();
	var content = document.getElementsByTagName('meta');
	var wait=60;
	for(var i = 0; i < content.length; i++){
		if(content[i].getAttribute('name') == 'Authcode')
			meta.appurl = content[i].getAttribute('content');
		if(content[i].getAttribute('name') == 'appurl')
			meta.verifyImg = content[i].getAttribute('content');
		if(content[i].getAttribute('name') == 'upload')
			meta.upload = content[i].getAttribute('content');
		if(content[i].getAttribute('name') == 'angular')
			meta.angular = content[i].getAttribute('content');
		if(content[i].getAttribute('name') == 'appId')
			meta.appId = content[i].getAttribute('content');
		if(content[i].getAttribute('name') == 'timestamp')
			meta.timestamp = content[i].getAttribute('content');
		if(content[i].getAttribute('name') == 'nonceStr')
			meta.nonceStr = content[i].getAttribute('content');
		if(content[i].getAttribute('name') == 'signature')
			meta.signature = content[i].getAttribute('content');
	}
	function closeWindows(){
		$('#dialog_alert').hide();
		wx.ready(function(){
			wx.closeWindow();
		});
	}
	angular.module('myApp', ['myApp.controllers', 'myApp.services', 'myApp.directive']);
	angular.module('myApp.services', [])
	.factory('myService', function($http){
		return {
			suregisterrvey: function(data){
				"获得用户详细数据";
				return $http({
					url: meta.angular,
					method: 'post',
					data: angular.extend({ac: 'onePagePost', op: 'register'}, data)
				});
			}
		};
	});
	angular.module('myApp.directive', [])
			.directive('uploadWidget', function(){
				"上传指令";
				return {
					restrict: 'A',
					template: '<ul class="weui_uploader_files"></ul><div class="weui_uploader_input_wrp"><input class="weui_uploader_input" type="button" /></div>',
					link: function(scope, elements, attrs){
						elements.bind('click', function(){
							wx.ready(function(){
								var count = (attrs.uploadWidget == 'survey_other')?9:1;
								wx.chooseImage({
									count: count, // 默认9
									sizeType: ['original', 'compressed'],   // 可以指定是原图还是压缩图，默认二者都有
									sourceType: ['album', 'camera'],        // 可以指定来源是相册还是相机，默认二者都有
									success: function (res) {
										var localIds = res.localIds;        // 返回选定照片的本地ID列表，localId可以作为img标签的src属性显示图片
										elements.find('ul').prepend('<li class="weui_uploader_file"><img src="' + localIds + '" /></li>');
										wx.uploadImage({
											localId: localIds.toString(),
											isShowProgressTips: 1,
											success: function (resu) {
												var serverId = resu.serverId;
												elements.find('div').addClass('hidden');
												switch(attrs.uploadWidget){
													case 'survey_1':
														scope.surveyModel.survey_1 = serverId;
														break;
													case 'survey_2':
														scope.surveyModel.survey_2 = serverId;
														break;
													case 'survey_other':
														scope.surveyModel.survey_other = serverId;
														break;
												}
											}
										});
									}
								});
							});
						});
					}
				}
			});
	angular.module('myApp.controllers', [])
	.controller('registerCtrl', function($scope, myService){
		$scope.submit = function(){
			$('#loading_toast').show();
			myService.register($scope.register).success(function(resp){
				$('#dialog_content').text(resp.content);
				$('#loading_toast').hide();
				$('#dialog_alert').show();
			});
		}
	});
</script>
</body>
</html>